/* ws2812b_gpio.h */

#ifndef __WS2812B_GPIO_H__
#define __WS2812B_GPIO_H__

#include "bsp_config.h"

#define WS2812B_RESET_COUNT         600U    
#define WS2812B_DATA_BIT_COUNT_MAX  24U
#define BSP_WS2812B_LED_COUNT       2U

#define WS2812B_GLED_SHIFT(x)                   ((uint32_t)(x) << 16U)
#define WS2812B_RLED_SHIFT(x)                   ((uint32_t)(x) << 8U)
#define WS2812B_BLED_SHIFT(x)                   ((uint32_t)(x))
#define WS2812B_COLOR_GREEN                     0xFF0000
#define WS2812B_COLOR_GREEN_INTENSITY           ( ((WS2812B_COLOR_GREEN>>16)/WS2812B_GREEN_INTENSITY_SCALE) << 16U )
#define WS2812B_COLOR_RED                       0xFF00
#define WS2812B_COLOR_RED_INTENSITY             ( ((WS2812B_COLOR_RED>>8)/WS2812B_RED_INTENSITY_SCALE) << 8U )
#define WS2812B_COLOR_RED_WEAK                  ( ((WS2812B_COLOR_RED>>8)/WS2812B_RED_WEAK_SCALE) << 8U )
#define WS2812B_COLOR_RED_BREATHE(x)            ( WS2812B_RLED_SHIFT((WS2812B_COLOR_RED_WEAK>>8U)*x/100) )
#define WS2812B_COLOR_BLUE                      0xFF
#define WS2812B_COLOR_BLUE_STRONG               WS2812B_COLOR_BLUE_INTENSITY * 2
#define WS2812B_COLOR_BLUE_INTENSITY            ( WS2812B_COLOR_BLUE/WS2812B_BLUE_INTENSITY_SCALE )
#define WS2812B_COLOR_BLUE_WEAK                 ( WS2812B_COLOR_BLUE/WS2812B_BLUE_WEAK_SCALE )
#define WS2812B_COLOR_BLUE_BREATHE(x)           ( WS2812B_COLOR_BLUE_WEAK*x/100 )
#define WS2812B_COLOR_WHITE                     WS2812B_COLOR_GREEN + WS2812B_COLOR_RED + WS2812B_COLOR_BLUE
#define WS2812B_COLOR_WHITE_INTENSITY           WS2812B_COLOR_GREEN_INTENSITY + WS2812B_COLOR_RED_INTENSITY + WS2812B_COLOR_BLUE_INTENSITY
#define WS2812B_COLOR_ORANGE                    WS2812B_RLED_SHIFT(0x25) + WS2812B_GLED_SHIFT(0x11) + WS2812B_BLED_SHIFT(0x01)
#define WS2812B_COLOR_YELLOW                    WS2812B_RLED_SHIFT(0xFF) + WS2812B_GLED_SHIFT(0x8C) + WS2812B_BLED_SHIFT(0x00)
#define WS2812B_COLOR_NON                       0x000000
#define WS2812B_GREEN_INTENSITY_SCALE           8U
#define WS2812B_RED_INTENSITY_SCALE             8U
#define WS2812B_RED_WEAK_SCALE                  12U
#define WS2812B_BLUE_INTENSITY_SCALE            8U
#define WS2812B_BLUE_WEAK_SCALE                 12U


void WS2812B_Init(void);
void WS2812B_ResetRight(void);
void WS2812B_ResetLeft(void);
void WS2812B_DoUpdateColorRight(uint32_t color);
void WS2812B_DoUpdateColorLeft(uint32_t color);
void WS2812B_DoUpdateColorRightOneByOne(uint32_t led1_color, uint32_t led2_color, uint32_t led3_color);
void WS2812B_DoUpdateColorLeftOneByOne(uint32_t led1_color, uint32_t led2_color, uint32_t led3_color);

#endif /* __WS2812B_GPIO_H__ */

